xen/arm: p2m don't fall over on FEAT_LPA enabled hw
authorAlex Bennée <alex.bennee@linaro.org>
Thu, 28 Apr 2022 10:34:10 +0000 (11:34 +0100)
committerStefano Stabellini <stefano.stabellini@amd.com>
Wed, 3 Aug 2022 21:57:36 +0000 (14:57 -0700)
commitfe02a5342d3ef372ac8eea12dcdbdf3ff7c47379
tree9044c88d22e3728f7e57091bf559bb504e4dbf93
parent271e9e860b7b5ee5fc01a8fd539aa7e1bcb096c6
xen/arm: p2m don't fall over on FEAT_LPA enabled hw

When we introduced FEAT_LPA to QEMU's -cpu max we discovered older
kernels had a bug where the physical address was copied directly from
ID_AA64MMFR0_EL1.PARange field. The early cpu_init code of Xen commits
the same error by blindly copying across the max supported range.

Unsurprisingly when the page tables aren't set up for these greater
ranges hilarity ensues and the hypervisor crashes fairly early on in
the boot-up sequence. This happens when we write to the control
register in enable_mmu().

Attempt to fix this the same way as the Linux kernel does by gating
PARange to the maximum the hypervisor can handle. I also had to fix up
code in p2m which panics when it sees an "invalid" entry in PARange.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien@xen.org>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Cc: Bertrand Marquis <bertrand.marquis@arm.com>
Tested-by: Luca Fancellu <luca.fancellu@arm.com>
Acked-by: Julien Grall <jgrall@amazon.com>
(cherry picked from commit 407b13a71e324aba76b11e5f66f59ce4a304a088)
xen/arch/arm/arm64/head.S
xen/arch/arm/p2m.c